B Binance · The world's largest crypto exchangeBinance Sign up → AD OKX OKX · A leading global crypto exchangeOKX Sign up → AD

Regex Tester

See matches instantly as you type

/ /

What this tool does

Enter a regular expression, flags and some test text, and matches are highlighted as you type, with the total count and a list of each match's position and capture group values. Use it to build patterns for checking email or phone number formats, refine an expression that pulls lines out of a log, or see what someone else's regex actually catches.

How it is calculated

The pattern runs as is on the JavaScript regular expression engine built into your browser. Any change to the pattern, flags or text reruns it immediately, and a syntax error turns the input red and shows the engine's error message. With the g flag on, every match to the end of the text is found; with it off, only the first. Zero-length matches (for example a pattern of just ^ or \b) are counted by stepping forward one position, so there is no infinite loop. For example, the pattern (\d{3})-(\d{4}) on '010-1234-5678' yields one match, '010-1234', with groups "010" and "1234". Characters already consumed are not reused, so '234-5678' is not matched separately. The list shows up to the first 50 matches with number, start index (counting from 0), matched string and group values. Everything runs in your browser.

  • Type the pattern between the slashes. A simple email pattern is filled in as an example.
  • Choose flags: g global, i ignore case, m multiline, s dot matches newlines.
  • Flags without a checkbox (u, y and so on) can be typed into the flags box on the right (up to 6 characters).
  • Paste your test text and the matches are highlighted in the preview.
  • Check the count, each match's position and capture group values in the list below.

Things to know

  • If only one match appears, first check whether the g flag is off.
  • ^ and $ mean the start and end of the whole text by default. Turn on m to apply them per line.
  • The dot does not match newlines by default. Turn on s to capture blocks across lines.
  • Escape special characters such as . * + ? ( ) [ ] { } | \ ^ $ with \ to match them literally. Slashes need no escaping in this box.
  • Greedy patterns like \d+ or .* grab more than expected. Add ? as in .*? for the shortest match.
  • A group that did not take part in a match shows as undefined in the list, which is common with optional groups like (…)?.
  • The list shows at most 50 entries, but the total count includes every match.

Frequently asked questions

How do I match non-English letters?

\w covers only ASCII letters, digits and underscore. Use a code point range such as [\uAC00-\uD7A3] for Korean syllables, or turn on the u flag and use \p{L} to match a letter in any script.

What pattern should I use for email addresses?

A perfect email regex is extremely long. Usually [^\s@]+@[^\s@]+\.[^\s@]+ checks the shape, and a verification email confirms the address exists.

A pattern that works here fails in another language.

Regex engines differ slightly. This tool follows JavaScript, so lookbehind, named group syntax and Unicode handling can differ from Python, Java and others.

Is my text sent to a server?

No. The pattern runs only in your browser and the page has no code that sends your input anywhere. It disappears when you close the page.

← na.to home